﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
using Spymaster.Entities;

namespace Spymaster.Entities.Components
{
    public class MouseComponent
    {
        PlayerEntity entity;

        MouseState oldState;

        public MouseComponent(PlayerEntity player)
        {
            this.entity = player;

            oldState = new MouseState();
        }

        public void Update()
        {
            MouseState newState = Mouse.GetState();

            if (newState.LeftButton == ButtonState.Pressed && oldState.LeftButton != ButtonState.Pressed)
            {
                entity.FireWeapon();
            }

            oldState = newState;
        }

        public Vector2 GetMousePosition()
        {
            return new Vector2(oldState.X, oldState.Y);
        }
    }
}
